<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
<!-- creator-code-pasting.qdoc -->
  <title>Pasting and Fetching Code Snippets | Qt Creator Manual</title>
  <link rel="stylesheet" type="text/css" href="style/offline-simple.css" />
  <script type="text/javascript">
    document.getElementsByTagName("link").item(0).setAttribute("href", "style/offline.css");
    // loading style sheet breaks anchors that were jumped to before
    // so force jumping to anchor again
    setTimeout(function() {
        var anchor = location.hash;
        // need to jump to different anchor first (e.g. none)
        location.hash = "#";
        setTimeout(function() {
            location.hash = anchor;
        }, 0);
    }, 0);
  </script>
</head>
<body>
<div class="header" id="qtdocheader">
  <div class="main">
    <div class="main-rounded">
      <div class="navigationbar">
        <table><tr>
<td ><a href="index.html">Qt Creator Manual</a></td><td >Pasting and Fetching Code Snippets</td></tr></table><table class="buildversion"><tr>
<td id="buildversion" width="100%" align="right"><a href="index.html">Qt Creator Manual 4.11.1</a></td>
        </tr></table>
      </div>
    </div>
<div class="content">
<div class="line">
<div class="content mainContent">
  <link rel="prev" href="qt-quick-toolbars.html" />
  <link rel="next" href="creator-macros.html" />
<p class="naviNextPrevious headerNavi">
<a class="prevPage" href="qt-quick-toolbars.html">Using Qt Quick Toolbars</a>
<span class="naviSeparator">  &#9702;  </span>
<a class="nextPage" href="creator-macros.html">Using Text Editing Macros</a>
</p><p/>
<div class="sidebar">
<div class="toc">
<h3><a name="toc">Contents</a></h3>
<ul>
<li class="level1"><a href="#specifying-settings-for-code-pasting">Specifying Settings for Code Pasting</a></li>
<li class="level1"><a href="#using-code-pasting-services">Using Code Pasting Services</a></li>
</ul>
</div>
<div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">Pasting and Fetching Code Snippets</h1>
<span class="subtitle"></span>
<!-- $$$creator-editor-codepasting.html-description -->
<div class="descr"> <a name="details"></a>
<p>In Qt Creator, you can paste snippets of code to a server or fetch snippets of code from the server. To paste and fetch snippets of code, Qt Creator uses the following:</p>
<ul>
<li><b>Pastebin.Com</b></li>
<li><b>Pastecode.Xyz</b></li>
<li><b>Shared network drives</b></li>
</ul>
<a name="specifying-settings-for-code-pasting"></a>
<h2 id="specifying-settings-for-code-pasting">Specifying Settings for Code Pasting</h2>
<p>To specify settings for the code pasting service:</p>
<ol class="1" type="1"><li>Select <b>Tools</b> &gt; <b>Options</b> &gt; <b>Code Pasting</b>.<p class="centerAlign"><img src="images/qtcreator-code-pasting-options.png" alt="&quot;Code Pasting options&quot;" /></p></li>
<li>In the <b>Default protocol</b> field, select a code pasting service to use by default.</li>
<li>In the <b>Username</b> field, enter your username.</li>
<li>In the <b>Expires after</b> field, specify the time to keep the pasted snippet on the server.</li>
<li>Select the <b>Copy-paste URL to clipboard</b> check box to copy the URL of the post on the code pasting service to the clipboard when you paste a post.</li>
<li>Select the <b>Display Output pane after sending a post</b> check box to display the URL in the <b>General Messages</b> output pane when you paste a post.</li>
</ol>
<p>Select <b>Fileshare</b> to specify the path to a shared network drive. The code snippets are copied to the drive as simple files. You have to delete obsolete files from the drive manually.</p>
<a name="using-code-pasting-services"></a>
<h2 id="using-code-pasting-services">Using Code Pasting Services</h2>
<p>To paste a snippet of code onto the server, select <b>Tools</b> &gt; <b>Code Pasting</b> &gt; <b>Paste Snippet</b> or press <b>Alt+C,Alt+P</b>. By default, Qt Creator copies the URL of the snippet to the clipboard and displays the URL in the <b>General Messages</b> output pane.</p>
<p>To paste any content that you copied to the clipboard, select <b>Tools</b> &gt; <b>Code Pasting</b> &gt; <b>Paste Snippet</b>.</p>
<p>To paste content from the <a href="creator-diff-editor.html">diff editor</a>, right-click a chunk and select <b>Send Chunk to CodePaster</b> in the context menu.</p>
<p>To fetch a snippet of code from the server, select <b>Tools</b> &gt; <b>Code Pasting</b> &gt; <b>Fetch Snippet</b> or press <b>Alt+C,Alt+F</b>. Select the snippet to fetch from the list.</p>
<p>To fetch the content stored at an URL, select <b>Tools</b> &gt; <b>Code Pasting</b> &gt; <b>Fetch from URL</b>.</p>
<p>For example, you might ask colleagues to review a change that you plan to submit to a version control system. If you use the Git version control system, you can create a <i>diff</i> view by selecting <b>Tools</b> &gt; <b>Git</b> &gt; <b>Local Repository</b> &gt; <b>Diff</b>. You can then upload its contents to the server by selecting <b>Tools</b> &gt; <b>Code Pasting</b> &gt; <b>Paste Snippet</b>. The reviewers can retrieve the code snippet by selecting <b>Tools</b> &gt; <b>Code Pasting</b> &gt; <b>Fetch Snippet</b>. If they have the project currently opened in Qt Creator, they can apply and test the change by choosing <b>Tools</b> &gt; <b>Git</b> &gt; <b>Local Repository</b> &gt; <b>Patch</b> &gt; <b>Apply from Editor</b>.</p>
</div>
<!-- @@@creator-editor-codepasting.html -->
<p class="naviNextPrevious footerNavi">
<a class="prevPage" href="qt-quick-toolbars.html">Using Qt Quick Toolbars</a>
<span class="naviSeparator">  &#9702;  </span>
<a class="nextPage" href="creator-macros.html">Using Text Editing Macros</a>
</p>
        </div>
       </div>
   </div>
   </div>
</div>
<div class="footer">
   <p>
   <acronym title="Copyright">&copy;</acronym> 2019 The Qt Company Ltd.
   Documentation contributions included herein are the copyrights of
   their respective owners.<br>    The documentation provided herein is licensed under the terms of the    <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation    License version 1.3</a> as published by the Free Software Foundation.<br>    Qt and respective logos are trademarks of The Qt Company Ltd.     in Finland and/or other countries worldwide. All other trademarks are property
   of their respective owners. </p>
</div>
</body>
</html>
